import {Button, Input} from "antd";
import { useRef, useState} from "react";
import AddDialog from "./Components/addDialog.tsx";
import ProjectBox from "./Components/projectBox.tsx";

const ResearchProject = () =>{
    const [projectName,setProjectName] = useState('')
    const addDialog =useRef()
    const projectBox = useRef()
    const searchProject = ()=>{
        projectBox?.current?.query()
    }
    const openAddDialog = () => {
        // 这里可以添加父组件需要执行的逻辑
        addDialog.current?.open()
    };
    return(
        <div>
            <div style={{display:'flex',alignItems:'center',justifyContent:'space-between',height:'100%'}}>
                <Input
                    value={projectName}
                    placeholder="请输入项目名称"
                    style={{width:'30%'}}
                    onBlur={searchProject}
                    onChange={(e)=> {
                        setProjectName(e.target.value)
                    }}
                />
                <Button type="primary" onClick={openAddDialog}>增加</Button>
            </div>
            <ProjectBox ref={projectBox} projectName={projectName} />
            <AddDialog ref={addDialog} />
        </div>
    )
}

export default ResearchProject